import Components from 'unplugin-vue-components/vite'
import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import prismjs from 'vite-plugin-prismjs'
import AutoImport from 'unplugin-auto-import/vite'

import { defineConfig } from 'vite'
import { resolve } from 'path'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  base: '/vue3-demo/',
  plugins: [
    vue(),
    Components({
      resolvers: [AntDesignVueResolver()]
    }),
    VueSetupExtend(),
    prismjs({
      languages: ['json']
    }),
    AutoImport({
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/ // .md
      ],
      imports: ['vue', 'vue-router', 'pinia', '@vueuse/core']
    })
  ],
  server: { host: '0.0.0.0', port: 9898 },
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, 'src')
      }
    ]
  }
})
